home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Creation Date: May 23, 1997
- // Author: sw
- //
- // Procedure Name:
- // AEglobalCacheControlTemplate
- //
- // Description Name;
- // Creates the attribute editor controls for the globalCacheControl Node
- //
- // Input Value:
- // nodeName
- //
- // Output Value:
- // None
- //
-
- global proc AEcacheControlReplace()
- {
- string $currentMenu = `optionMenuGrp -q -v cacheMenu`;
-
- int $totalMenuItems = `optionMenuGrp -q -numberOfItems cacheMenu`;
-
- string $allItemNames[] = `optionMenuGrp -q -ils cacheMenu`;
-
- string $nodes[] = `ls -type "diskCache"`;
- optionMenuGrp -e cacheMenu;
-
- int $nth;
- int $n = 0;
- string $mcj = "mcj";
- string $mcjNodes[];
- for( $nth = 1; $nth <= size($nodes); $nth++) {
- string $cacheType = `getAttr ($nodes[$nth-1] + ".cacheType")`;
- if( $cacheType == $mcj ) {
- $mcjNodes[$n] = $nodes[$nth-1];
- $n++;
- }
- }
-
- // If no disk cache exists
- if( size($mcjNodes) == 0 ) {
- // leave one menuItem and delte the rest
- // Set the first menu item to "No Disk Cache"
- menuItem -e -l "No Disk Cache" $allItemNames[0];
- $n = 1;
- } else {
- $n = size($mcjNodes);
- }
-
- // Delete the rest
- for( $nth = $n+1; $nth <= $totalMenuItems; $nth++ ) {
- string $itemName = $allItemNames[$nth-1];
- deleteUI $itemName;
- }
- if( size($mcjNodes) == 0 ) return;
-
- if( $totalMenuItems > $n ) $totalMenuItems = $n;
-
- // Build menu items for each disk cache
- int $currentNth = 1;
- for( $nth = 1; $nth <= $totalMenuItems; $nth++ ) {
- string $tmpName = `getAttr ($mcjNodes[$nth-1] + ".cacheName")`;
- if( size($tmpName) == 0 )
- $tmpName = `getAttr ($mcjNodes[$nth-1] + ".hiddenCacheName")`;
- if( $tmpName == $currentMenu ) $currentNth = $nth;
- optionMenuGrp -e -sl $nth cacheMenu;
- menuItem -e -l $tmpName $allItemNames[$nth - 1];
- }
- // This is a fix to get around the optionMenuGrp bug (#81337)
- string $fullName = `setParent "cacheMenu"`;
- string $menuName = ($fullName+"|OptionMenu");
- setParent -m $menuName;
- for( $nth = $totalMenuItems + 1; $nth <= size($mcjNodes); $nth++ ) {
- string $tmpName = `getAttr ($mcjNodes[$nth-1] + ".cacheName")`;
- if( size($tmpName) == 0 )
- $tmpName = `getAttr ($mcjNodes[$nth-1] + ".hiddenCacheName")`;
- if( $tmpName == $currentMenu ) $currentNth = $nth;
- menuItem -l $tmpName;
- }
-
- // Set the current menuItem
- optionMenuGrp -e -sl $currentNth cacheMenu;
- if( size($mcjNodes) >= 0 ) {
- string $selectedCache = $mcjNodes[$currentNth-1];
- connectControl -index 2 startTime ($selectedCache+".startTime");
- connectControl -index 2 endTime ($selectedCache+".endTime");
- connectControl -index 2 samplingRate ($selectedCache+".samplingRate");
- connectControl -index 2 samplingType ($selectedCache+".samplingType");
- } else {
- menuItem -l "No Disk Cache";
- floatFieldGrp -e -value1 0 startTime;
- floatFieldGrp -e -value1 0 endTime;
- optionMenuGrp -e -sl $currentNth samplingType;
- menuItem -l "Over Sample";
- intFieldGrp -e -value1 0 samplingRate;
- }
-
- setParent ..;
- }
-
- global proc AEcacheControlNew()
- {
- setUITemplate -pushTemplate attributeEditorTemplate;
- optionMenuGrp -label "Cache Name" cacheMenu;
- menuItem -l "No Disk Cache";
- setUITemplate -popTemplate;
-
- setUITemplate -pushTemplate attributeEditorTemplate;
- floatFieldGrp -nf 1 -en1 false -label "Start Time" startTime;
- floatFieldGrp -nf 1 -en1 false -label "End Time" endTime;
- optionMenuGrp -en false -label "Sampling Type" samplingType;
- menuItem -label "Over Sample";
- menuItem -label "Under Sample";
- intFieldGrp -nf 1 -en1 false -label "Sampling Rate" samplingRate;
- setUITemplate -popTemplate;
-
- AEcacheControlReplace;
- }
-
- global proc AEdeleteAllCache()
- {
- string $caches[] = `ls -type "diskCache"`;
- for( $c in $caches ) {
- // Only delete all *jiggle* caches...
- //
- if( `getAttr ($c + ".cacheType")` == "mcj" ) {
- diskCache -delete $c;
- }
- }
-
- AEcacheControlReplace;
- }
-
- global proc AEdeleteAllCacheNew()
- {
- setUITemplate -pst attributeEditorTemplate;
- rowLayout -nc 2;
- text -l " ";
- button -label "Delete All Caches"
- -c ("evalEcho AEdeleteAllCache")
- -width 80 deleteAllCache;
- setParent ..;
- setUITemplate -ppt;
- }
-
- global proc AEdeleteAllCacheReplace()
- {
-
- }
-
- global proc AEglobalCacheEnableNew()
- //
- // Description:
- // Create the option menu for enabling/disabling all
- // jiggle caches.
- //
- {
- setUITemplate -pst attributeEditorTemplate;
-
- optionMenuGrp -l "Enable Status"
- -cc AEglobalCacheEnableChanged
- globalCacheEnable;
-
- menuItem -l "Enable All";
- menuItem -l "Disable All";
- setParent ..;
-
- setUITemplate -ppt attributeEditorTemplate;
-
- AEglobalCacheEnableReplace();
- }
-
- global proc AEglobalCacheEnableReplace()
- //
- // Description:
- // We have to "connect" the option menu so that it displays
- // the right value : are all jiggle caches enabled or disabled?
- //
- {
- int $onCount = 0;
- int $offCount = 0;
- int $jiggleCount = 0;
-
- string $caches[] = `ls -type diskCache`;
- for( $c in $caches ) {
- if( `getAttr ($c + ".cacheType" )` != "mcj" ) {
- continue;
- }
-
- $jiggleCount++;
-
- if( `getAttr ( $c + ".enable" )` ) {
- $onCount++;
- } else {
- $offCount++;
- }
- }
-
- // Select the All Enabled item
- //
- if( $onCount == $jiggleCount ) {
- optionMenuGrp -e -v "Enable All" globalCacheEnable;
- }
- // Select the All Disbled item
- //
- else if( $offCount == $jiggleCount ) {
- optionMenuGrp -e -v "Disable All" globalCacheEnable;
- }
- // Cache status is mixed. If we're showing
- // UI that indicates they're all on or all off,
- // we'd better set them that way...
- //
- // Note that there's no UI to turn an individual
- // diskCache node on or off, so this actually
- // shouldn't really even happen...
- //
- else {
- AEglobalCacheEnableChanged();
- }
- }
-
- proc AEglobalCacheSetAllJiggle( int $enable )
- //
- // Description:
- // Helper proc to set the enabled state of all jiggle caches.
- //
- {
- string $caches[] = `ls -type diskCache`;
- for( $c in $caches ) {
- if( `getAttr ($c + ".cacheType" )` != "mcj" ) {
- continue;
- }
-
- setAttr ( $c + ".enable" ) $enable;
- }
- }
-
- global proc AEglobalCacheEnableChanged()
- //
- // Description:
- // Take the current value of the option menu and apply it
- // to all jiggle caches in the scene.
- //
- {
- string $status = `optionMenuGrp -q -value globalCacheEnable`;
- if( $status == "Enable All" ) {
- AEglobalCacheSetAllJiggle( true );
- } else if( $status == "Disable All" ) {
- AEglobalCacheSetAllJiggle( false );
- }
- }
-
- global proc AEglobalCacheControlTemplate ( string $nodeName )
- {
- editorTemplate -beginLayout "Control For All Caches" -collapse false;
- editorTemplate -suppress enableStatus;
- editorTemplate -callCustom "AEglobalCacheEnableNew" "AEglobalCacheEnableReplace";
-
- editorTemplate -callCustom "AEdeleteAllCacheNew" "AEdeleteAllCacheReplace";
- editorTemplate -endLayout;
-
- editorTemplate -beginLayout "Individual Cache Status" -collapse false;
- editorTemplate -callCustom "AEcacheControlNew"
- "AEcacheControlReplace" ;
- editorTemplate -endLayout;
-
- editorTemplate -suppress writeEnable;
-
- AEdependNodeTemplate $nodeName;
-
- editorTemplate -addExtraControls;
-
- }
-